package com.msb.apiDriver.service;

import com.msb.apiDriver.remote.ServiceDriverUserClient;
import com.msb.apiDriver.remote.ServiceMapClient;
import com.msb.internalcommon.dto.Car;
import com.msb.internalcommon.dto.ResponseResult;
import com.msb.internalcommon.request.ApiDrivePointRequest;
import com.msb.internalcommon.request.PointRequest;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: jiudianliu
 * @Date: 2023/7/9 - 07 - 09 - 16:13
 * @Description: com.msb.apiDriver.service
 * @version: 1.0
 */
@Service
public class PointService {

    @Autowired
    private ServiceDriverUserClient serviceDriverUserClient ;

    @Autowired
    private ServiceMapClient serviceMapClient ;


    public ResponseResult upload(ApiDrivePointRequest apiDrivePointRequest) {

        //获取carID
        Long carId = apiDrivePointRequest.getCarId();

        //通过carID 获取tid和trid，通过调用 service-driver-user 的接口
        ResponseResult<Car> carById = serviceDriverUserClient.getCarById(carId);
        Car data = carById.getData();
        String tid = data.getTid();
        String trid = data.getTrid();

        //调用地图服务进行上传
        PointRequest pointRequest = new PointRequest() ;
        pointRequest.setTid(tid);
        pointRequest.setTrid(trid);
        pointRequest.setPoints(apiDrivePointRequest.getPoints());
        return serviceMapClient.upload(pointRequest);
    }
}
